@import "ui-variables";
@import "syntax-variables";

.list-tree.has-collapsable-children .list-nested-item > .list-item.loading:before {
  content: "\f087"; // 'sync' icon, spinning arrows
}

/*
 * Styles below taken from Atom's [tree-view][0] to ensure nuclide-file-tree looks exactly the same.
 *
 * [0] https://github.com/atom/tree-view
 */
.tree-view {
  flex-grow: 1;
  flex-shrink: 0;
  min-height: min-content; // Switched from tree-view's `100%` to fill height of scroller.
  padding-left: @component-icon-padding;
  padding-right: @component-padding;
  position: relative;
  width: 100%;

  .header {
    position: relative;
  }

  .list-tree {
    min-width: min-content;
    position: static;
  }

  .entry {
    position: relative;
    // This fixes https://github.com/atom/tree-view/issues/110, see that issue for more details
    &:before {
      content: '';
      position: absolute;
    }

    .name {
      // Give the text a little breathing room.
      padding-right: @component-padding / 2;
    }
  }

  .nuclide-ui-checkbox[type="checkbox"] {
    &:indeterminate {
      background-color: @text-color-warning;
    }
    &:checked,
    &:active {
      background-color: @background-color-success;
    }

    // Note: Atom applies transitions to the checkmarks, but when applied to
    // hundreds of checkboxes simultaneously as is the case in the
    // 'nuclide-file-tree' package w/Working Sets, they are too expensive to
    // paint. The followings styles intentionally omit transitions.
    &,
    &:before,
    &:after {
      transition: none;
    }
  }

  &:focus .selected {
    .list-item,
    .name {
      color: contrast(@button-background-color-selected) !important;
    }

    &::before {
      background: @button-background-color-selected;
    }
  }

  .selection-indicator::before {
    // We explicitly set the height on the selection indicator, so we want to
    // make sure the pseudoelement (which gets the background color) takes up
    // all of it.
    height: 100% !important;
  }

  // Our selection indicators are behind the entries; we don't want to use the
  // selected entries themselves (like the normal Atom tree-view does).
  .entry.selected::before {
    display: none !important;
  }
}

// This is almost identical to the .nuclide-ui-panel-component-scroller, but without the
// overflow: scroll, since the scrolling is being done by the react-virtualized elements
.file-tree-scroller {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  /*
   * Chromium on OS X with a Touchpad acts like scrolling containers have
   * `overflow-scrolling: touch;` content, which creates large, extraneous layers in the
   * nuclide-file-tree because of the new stacking context. Force a new stacking context and
   * wrapping layer to prevent Chromium from creating those extraneous layers.
   *
   * This dramatically reduces the cost of layer tree updates ("Update Layer Tree" events in the
   * devtools "Timeline" tab) that occur frequently while typing.
   */
  isolation: isolate;
}

.nuclide-file-tree-filter {
  &.not-found {
    color: @text-color-error;
  }
  font-weight: bold;
  position: absolute;
  margin-top: @component-padding;
  left: @component-padding;
  z-index: 1;
  background: @overlay-background-color;
  padding: @component-padding/2 @component-padding;
  border: 1px solid @overlay-border-color;
  transition: opacity 0.5s;
  display: none;
}

.nuclide-file-tree-entry-highlight {
  color: @text-color-highlight;
  font-weight: bold;
}

.nuclide-file-tree-fixed {
  position: relative;
}

.nuclide-file-tree-toolbar {
  margin-top: 10px;
  position: absolute;
  right: 30px;
  z-index: 1;
}

.nuclide-file-tree-toolbar-container {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  background-color: @tree-view-background-color;
}

.nuclide-file-tree-toolbar-fader {
  opacity: 0;
  transition: opacity 0.35s ease-in-out;
}

.nuclide-file-tree-toolbar-container:hover .nuclide-file-tree-toolbar-fader {
  opacity: 1;
}

.nuclide-file-tree .list-item .nuclide-ui-checkbox-label {
  margin-right: 5px;
}

.nuclide-file-tree-softened {
  opacity: 0.4;
}

.nuclide-file-tree-root-being-reordered {
  opacity: 0.5;
}

.nuclide-file-tree-locked-height {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
}

.nuclide-file-tree-working-set-name-missing {
  visibility: hidden;
}

// matches the margin in .inline-block-tight
.nuclide-file-tree-connection-title {
  margin-left: @component-padding/2;
}

.nuclide-file-tree-open-files-section {
  display: flex;
  flex-direction: column;
}

.nuclide-file-tree-open-files-section > .nuclide-ui-section-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.nuclide-file-tree-open-files {
  display: flex;
  height: 100%;
  max-height: inherit;
}

.nuclide-file-tree-open-files-list {
  position: relative;
  width: 100%;
  min-width: min-content;

  .list-item:hover {
    color: @text-color-highlight;
  }

  .icon-primitive-dot:before,
  .icon-x:before {
    font-size: 12px;
    height: @component-icon-size;
    width: @component-icon-size;
  }
}

.nuclide-file-tree-open-files-row {
  display: flex;
  width: 100%;
}

.nuclide-file-tree-section-caption {
  padding-left: 5px;
  padding-right: 5px;
}

.nuclide-file-tree-spinner {
  position: absolute;
}

.nuclide-file-tree-sidebar-uncommitted-changes-container {
  height: 100%;
  max-height: inherit;
}

.nuclide-file-tree-sidebar-uncommitted-changes {
  display: flex;
  width: 100%;
}

.nuclide-file-tree .list-item {
  position: relative;
}

.nuclide-file-tree .list-item::before {
  vertical-align: middle;
}

.nuclide-file-tree.tree-view .list-item.selected.selected {
  padding-top: 0;
  margin-top: 0;
}

// Override the One themes' negative margins which make the row too wide and
// force the horizontal scrollbar always.
// See https://github.com/atom/one-light-ui/blob/739a62d551183a464045bf08d9ca43dda3dc56c3/styles/config.less#L114
.tree-view.tree-view.tree-view .project-root.project-root {
  margin-right: 0;
}
